package com.fhz.mvvm.ui.main;

import androidx.lifecycle.LiveData;

import com.fhz.mvvm.ServiceApi;
import com.fhz.mvvm.callback.ApiResponse;
import com.fhz.mvvm.entity.Banner;
import com.fhz.mvvm.entity.GoodsInfo;
import com.fhz.mvvm.entity.GoodsInfoLocal;
import com.fhz.mvvm.ui.main.datasource.MainLocalDataSource;
import com.fhz.mvvm.ui.main.datasource.MainRetrofitDataSource;
import com.fhz.mvvm.util.RetrofitMananger;

import java.util.List;

import javax.inject.Inject;

import io.reactivex.Observable;
import retrofit2.http.Query;

/**
 * 时间:2023/8/17
 *
 * @author Mr.Feng
 * 简述: 仓库
 */
public class MainRepository {
    @Inject
    public MainLocalDataSource mMainLocalDataSource;
    @Inject
    public MainRetrofitDataSource mMainRetrofitDataSource;

    @Inject
    public MainRepository(MainLocalDataSource mainLocalDataSource, MainRetrofitDataSource mainRetrofitDataSource) {
        mMainLocalDataSource = mainLocalDataSource;
        mMainRetrofitDataSource = mainRetrofitDataSource;
    }

    public LiveData<ApiResponse<Banner>> getBanner(@Query("type") int type, @Query("page") int page, @Query("pageSize") int pageSize){
        return mMainRetrofitDataSource.getBanner(type, page, pageSize);
    }

    public LiveData<ApiResponse<GoodsInfo>> getGoodsInfo(@Query("page") int page, @Query("pageSize") int pageSize){
        return mMainRetrofitDataSource.getGoodsInfo(page,pageSize);
    }

    public void insertGoodsInfo(GoodsInfoLocal goodsInfoLocal){
         mMainLocalDataSource.insertGoodsInfo(goodsInfoLocal);
    }

    public LiveData<List<GoodsInfoLocal>> getAllGoods(){
        return mMainLocalDataSource.getAllGoods();
    }
}
